package com.lrkj.back.service.impl;

import java.util.List;
import java.util.Map;

import com.lrkj.back.entity.TbPackageProduct;
import com.lrkj.back.mapper.TbPackageProductMapper;
import com.lrkj.back.service.TbPackageProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.com.cbons.mamisay.parent.db.api.DBInterface;
import cn.com.cbons.mamisay.parent.exception.DBException;
import cn.com.cbons.mamisay.parent.service.base.ParentServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Transactional
@Service("packageProductService")
public class TbPackageProductServiceImpl extends ParentServiceImpl<TbPackageProduct> implements TbPackageProductService {

    @Autowired
    private TbPackageProductMapper packageProductMapper;

    @Override
    protected DBInterface<TbPackageProduct> getDao() throws DBException {
        return packageProductMapper;
    }

    @Override
    public List<TbPackageProduct> selectByPackageId(String id) throws DBException {
        return packageProductMapper.selectByPackageId(id);
    }

    @Override
    public int deleteByPackageId(String packageId) throws DBException {
        return packageProductMapper.deleteByPackageId(packageId);
    }

    @Override
    public List<TbPackageProduct> queryProductListByDepIds(Map<String, Object> map) throws DBException {
        return packageProductMapper.queryProductListByDepIds(map);
    }

    @Override
    public PageInfo<TbPackageProduct> selectAllDetais(Map<String, Object> map) throws DBException {
        PageHelper.startPage(Integer.valueOf(map.get("pageNo").toString()),
                Integer.valueOf(map.get("pageSize").toString()));
        List<TbPackageProduct> mfList = packageProductMapper.findAllDetais(map);
        PageInfo<TbPackageProduct> page = new PageInfo<TbPackageProduct>(mfList);
        return page;
    }

    @Override
    public List<TbPackageProduct> findAllPackageProduct(Map<String, Object> map) throws DBException {
        // TODO Auto-generated method stub
        return packageProductMapper.findAllPackageProduct(map);
    }

    @Override
    public void deleteByPackageQixieMuban(TbPackageProduct st) throws DBException {
        // TODO Auto-generated method stub
        packageProductMapper.deleteByPackageQixieMuban(st);
    }

    @Override
    public void updateQixieMun(TbPackageProduct st) throws DBException {
        packageProductMapper.updateQixieMun(st);

    }

    @Override
    public int insertBatch(List<TbPackageProduct> list) throws DBException {
        return packageProductMapper.insertBatch(list);
    }

    @Override
    public int selectNumByPackageId(String packageId) throws DBException{
        return packageProductMapper.selectNumByPackageId(packageId);
    }

}
